package com.zhenhe.common.controller;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhenhe.core.common.controller.BaseController;
import com.zhenhe.core.common.utils.security.AESUtil;
import com.zhenhe.core.entity.TUserEntity;
import com.zhenhe.core.modules.service.TUserService;

@Controller
public class MemberSync extends BaseController{

	private static final Logger log = LoggerFactory.getLogger(MemberSync.class);
	
	@Resource
	private TUserService memberService;
	
	@RequestMapping("memberSyncInfo")
	@ResponseBody
	public String getMemberInfo(
			@RequestParam(required=true) String cellphone,
			@RequestParam(required=true) String key){
		try{
			String hex = AESUtil.decryptHex(cellphone, key);
			TUserEntity member = memberService.findMember(hex);
			if(member==null){
				return "00";
			}
			String passwd = member.getPassword();
			String hex2 = AESUtil.encryptHex(passwd, key);
			return hex2;
		}catch(Exception e){
			log.warn("解码错误", e);
			return "01";
		}
		
		
		
	}
	
}
